<?php
define(IMPORT,'../class.mamatblog/',true);
require_once(IMPORT.'mysql.php');
require_once(IMPORT.'track.php');

$track = new Track();

$rowsPerPage = 30;
$pageNum = 1;

if(isset($_GET['page'])){
	$pageNum = addslashes($_GET['page']);
}

$offset = ($pageNum - 1) * $rowsPerPage;

$data = $track->getPageTrack($offset,$rowsPerPage);

$numrows = $track->getNumsRowPage();

$maxPage = ceil($numrows/$rowsPerPage);

//membuat option next, previous
if ($pageNum > 1)
{
	$page = $pageNum - 1;
	$prev = " <a href=\"#\" id=\"author\" onclick=\"makeRequest('showtrack.php?page=$page','main','Loading...!')\">[Prev]</a> ";	
	$first = "<a href=\"#\" id=\"author\" onclick=\"makeRequest('showtrack.php?page=1','main','Loading...!')\">[First Page]</a> ";
	
} 
else
{
	$prev  = ' [Prev] ';       // we're on page one, don't enable 'previous' link
	$first = ' [First Page] '; // nor 'first page' link
}

// print 'next' link only if we're not
// on the last page
if ($pageNum < $maxPage)
{
	$page = $pageNum + 1;
	$next = " <a href=\"#\" id=\"author\" onclick=\"makeRequest('showtrack.php?page=$page','main','Loading...!')\">[Next]</a> ";	
	$last = " <a href=\"#\" id=\"author\" onclick=\"makeRequest('showtrack.php?page=$maxPage','main','Loading...!')\">[Last Page]</a> ";
	
} 
else
{
	$next = ' [Next] ';      // we're on the last page, don't enable 'next' link
	$last = ' [Last Page] '; // nor 'last page' link
}

?>
<h2 class="first"><a href="#" id="author" onclick="makeRequest('showtrack.php?','main','Tunggu yak lagi Loading main page..!')">Terima Kasih buat Pengunjungn :)</a></h2>
<p class="postdata">

<?php echo "Total: <strong>$numrows</strong> pengunjung, ". $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last;?>
</p>
<p>
<?php
for($i=0;$i<count($data);$i++){
	if($i%2==0){
		echo "<div>".$data[$i][1]."</div>";
	} else {
		echo "<div>".$data[$i][1]."</div>";
	}
	echo "<div  style=\"background-color:#000000\" align=\"center\">----- <strong>".$data[$i][0]."</strong> -----</div>";
}
?>
</p>
<p class="postdata">

<?php echo "Total: <strong>$numrows</strong> pengunjung, ". $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last;?>
</p>